home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 November / Chip_2003-11_cd1.bin / program / delphi / kompon / BalmsoftPolyglot.exe / {app} / Demos / Delphi 5-7 / bsPolyglotDemoFrm.pas < prev    next >
Pascal/Delphi Source File  |  2003-08-11  |  3KB  |  131 lines

  1. unit bsPolyglotDemoFrm;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils,
  7.   {$IFDEF D6_OR_HIGHER}
  8.   Variants,
  9.   {$ENDIF}
  10.   Classes, Graphics, Controls, Forms,
  11.   Dialogs, StdCtrls, ExtCtrls, TypInfo, DB, Grids,
  12.   DBGrids, ADODB, bsPolyglotUn, bsPolyglotDemoMdl, Menus, ActnList;
  13.  
  14. type
  15.   TbsPolyglotDemoForm = class(TForm)
  16.     cbLanguages: TComboBox;
  17.     Label1: TLabel;
  18.     Memo1: TMemo;
  19.     Label2: TLabel;
  20.     Button1: TButton;
  21.     Panel1: TPanel;
  22.     ds: TADODataSet;
  23.     DataSource1: TDataSource;
  24.     dsFirstName: TStringField;
  25.     dsLastName: TStringField;
  26.     dsSalary: TCurrencyField;
  27.     ComboBox1: TComboBox;
  28.     Label3: TLabel;
  29.     RadioGroup1: TRadioGroup;
  30.     Button2: TButton;
  31.     Panel2: TPanel;
  32.     DBGrid1: TDBGrid;
  33.     bsPolyglotTranslator1: TbsPolyglotTranslator;
  34.     Label4: TLabel;
  35.     MainMenu1: TMainMenu;
  36.     ActionList1: TActionList;
  37.     Action1: TAction;
  38.     Action2: TAction;
  39.     Action11: TMenuItem;
  40.     Action21: TMenuItem;
  41.     PopupMenu1: TPopupMenu;
  42.     Action12: TMenuItem;
  43.     Action22: TMenuItem;
  44.     Button3: TButton;
  45.     Button4: TButton;
  46.     procedure FormCreate(Sender: TObject);
  47.     procedure cbLanguagesChange(Sender: TObject);
  48.     procedure Button1Click(Sender: TObject);
  49.     procedure Button2Click(Sender: TObject);
  50.   private
  51.     procedure FillDataset;
  52.     procedure FillLanguages;
  53.   public
  54.     { Public declarations }
  55.   end;
  56.  
  57. var
  58.   bsPolyglotDemoForm: TbsPolyglotDemoForm;
  59.  
  60. implementation
  61.  
  62. {$R *.dfm}
  63.  
  64. resourcestring
  65.   strYouSelected = 'You selected: ';
  66.  
  67. procedure TbsPolyglotDemoForm.FillDataset;
  68.   procedure AddRow(AFirstName, ALastName: string; ASalary: double);
  69.   begin
  70.     ds.Append;
  71.     try
  72.       dsFirstName.Value := AFirstName;
  73.       dsLastName.Value := ALastName;
  74.       dsSalary.Value := ASalary;
  75.       ds.Post;
  76.     except
  77.       ds.Cancel;
  78.       raise;
  79.     end;
  80.   end;
  81. begin
  82.   if ds.Active then
  83.     ds.Close;
  84.   ds.CreateDataset;
  85.   AddRow('John', 'Smith', 40000);
  86.   AddRow('Joe', 'Garper', 52000);
  87.   AddRow('Hose', 'Enrice', 35000);
  88.   AddRow('Alex', 'Square', 61000);
  89. end;
  90.  
  91. procedure TbsPolyglotDemoForm.FillLanguages;
  92. var
  93.   lPolyglot: TbsCorePolyglot;
  94.   i: Integer;
  95. begin
  96.   // same dir as exe file
  97.   DataModule1.PolyglotManager.LangsDir := ExtractFileDir(ParamStr(0));
  98.   cbLanguages.Items.Clear;
  99.   lPolyglot := TbsCorePolyglot.GetCorePolyglot;
  100.   for i := 0 to lPolyglot.LangCount - 1 do
  101.   begin
  102.     cbLanguages.Items.Add(lPolyglot.Langs[i]);
  103.     if lPolyglot.Langs[i] = lPolyglot.CurrentLang then
  104.       cbLanguages.ItemIndex := i;
  105.   end;
  106. end;
  107.  
  108. procedure TbsPolyglotDemoForm.FormCreate(Sender: TObject);
  109. begin
  110.   FillDataset;
  111.   FillLanguages;
  112. end;
  113.  
  114. procedure TbsPolyglotDemoForm.cbLanguagesChange(Sender: TObject);
  115. begin
  116.   DataModule1.PolyglotManager.CurrentLang := cbLanguages.Text;
  117.   FillLanguages;
  118. end;
  119.  
  120. procedure TbsPolyglotDemoForm.Button1Click(Sender: TObject);
  121. begin
  122.   MessageDlg(DataModule1.PolyglotManager.GetString('Messages', 'Message1'), mtInformation, [mbOk], 0);
  123. end;
  124.  
  125. procedure TbsPolyglotDemoForm.Button2Click(Sender: TObject);
  126. begin
  127.   MessageDlg(strYouSelected + RadioGroup1.Items.Strings[RadioGroup1.ItemIndex], mtInformation, [mbOk], 0);
  128. end;
  129.  
  130. end.
  131.